package servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import bean.Content;
import bean.Photo_news;

import dao.Annual_reportDao;
import dao.Campus_constructionDao;
import dao.Funding_informationDao;
import dao.Fundraising_projectDao;
import dao.ManageDao;
import dao.NewsDao;
import dao.Photo_newsDao;
import dao.ThanksDao;

public class ModifyServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String sid = req.getParameter("sid");
		String id = req.getParameter("id");

		HttpSession session = req.getSession();
		String choice_id2 = (String) session.getAttribute("choice_id");
		int choice_id = Integer.parseInt(choice_id2);

		Content content = null;
		switch (choice_id) {
		case 1:
			content = new Photo_newsDao().getContent(id, 1);
			break;
		case 2:
			content = new NewsDao().getContent(id, 1);
			break;
		case 3:
			content = new Funding_informationDao().getContent(id, 1);
			break;
		case 4:
			break;
		case 5:
			content = new ThanksDao().getContent(id);
			break;
		case 6:
			content = new ManageDao().getContent(id, 1);
			break;
		case 7:
			content = new Annual_reportDao().getContent(id, 1);
			break;
		case 8:
			content = new Fundraising_projectDao().getContent(id, 1);
			break;
		case 9:
			content = new Campus_constructionDao().getContent(id, 1);
			break;
		}

		session.setAttribute("content", content);
		session.setAttribute("find_insert_id", sid);

		resp.sendRedirect("houtai/guanli_1.jsp?id=" + choice_id);
	}
}
